//
// Description: 453. 最小操作次数使数组元素相等
// Created by Loading on 2021/10/20.
//

#include <bits/stdc++.h>

using namespace std;

int minMoves(vector<int> &nums) {
    /* 思路转变为：每次让 1 个元素减少 1，所有元素减少到最小值的次数即为答案 */
    int min_ele = *min_element(nums.begin(), nums.end());
    int res = 0;
    for (auto &x : nums) {
        res += x - min_ele;
    }

    return res;
}

int main() {
    vector<int> nums = {1, 2, 3};
    int res = minMoves(nums);
    cout << res << endl;

    return 0;
}